package org.sunyaxing.transflow.api.extensions.base.typesimpl;


import com.alibaba.fastjson2.JSONObject;
import org.sunyaxing.transflow.api.HandleData;
import org.sunyaxing.transflow.api.extensions.base.ExtensionContext;

public abstract class TransFlowMiddleJsonGatewayHandler extends TransFlowMiddleGatewayHandler<String, JSONObject, String> {
    public TransFlowMiddleJsonGatewayHandler(ExtensionContext extensionContext) {
        super(extensionContext);
    }

    @Override
    public HandleData<JSONObject> beforeHandle(HandleData<String> handleData) {
        return handleData.transTo(JSONObject::parseObject);
    }

    @Override
    public HandleData<String> afterHandle(HandleData<JSONObject> handleData) {
        return handleData.transTo((jsonObject) -> jsonObject.toJSONString());
    }
}
